<?php
/**
 * Create By: PhpStorm
 * User: niechenguang
 * File: Circle.php
 * Date: 2017/1/2
 * Time: 23:13
 */

namespace app\home\model\page\management;

use app\api\model\dao\Circle;
use app\api\model\dao\RecommendRank;
use app\home\model\UserAccount;
use app\library\Error;
use app\library\Flag;
use app\library\PageBase;
use think\Exception;
use think\Validate;

class DelRecommendUser extends PageBase
{
    private $objUserAccount;
    private $objRecommendRank;

    public function __construct()
    {
        parent::__construct();

        $this->objUserAccount = new UserAccount();
        $this->objRecommendRank = new RecommendRank();
    }


    /**
     * @param $param
     * @return array|bool
     * @DESC 验证接口字段
     */
    public function checkParam($param)
    {
        $rule = [
            'id' => 'require',
        ];
        $msg = [
            'id.require' => '请选择删除的序列号',
        ];

        $validate = new Validate($rule, $msg);
        $result = $validate->check($param);
        if (!$result) {
            return $validate->getError();
        }
        return '';
    }

    public function excute($param)
    {
//        $ret = $this->checkToken($param);
//        if (false === $ret) {
//            throw new Exception('check token fail...', Error::ERR_SYS);
//        }

        // 1、参数校验
        $ret = $this->checkParam($param);
        if ($ret) {
            return $this->getRes(Error::ERR_PARAM, $ret);
        }

        $ret = $this->objRecommendRank->delRecommendRankByid($param['id']);
        if (false === $ret) {
            return $this->getRes(Error::ERR_SYS);
        }
        return $this->getRes();
    }
}
